package com.solcoo.merchant.ui.level;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

import com.android.common.util.DensityUtil;
import com.solcoo.merchant.R;
import com.solcoo.merchant.base.BaseListAdapter;
import com.solcoo.merchant.model.Level;

public class LevelAdapter extends BaseListAdapter<Level> {

	private ListView.LayoutParams layoutParams = new ListView.LayoutParams(
			ListView.LayoutParams.MATCH_PARENT, DensityUtil.dip2px(90));

	public LevelAdapter(Context context) {
		super(context);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView != null) {
			holder = (ViewHolder) convertView.getTag(R.layout.level_item);
		} else {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.level_item, null);
			convertView.setLayoutParams(layoutParams);
			holder.levelValue = (TextView) convertView
					.findViewById(R.id.level_value);
			holder.levelInfo = (TextView) convertView
					.findViewById(R.id.level_info);
			convertView.setTag(R.layout.level_item, holder);
		}
		Level level = getItem(position);
		holder.levelValue.setText(String.valueOf(level.dengji));
		holder.levelInfo.setText("享受" + level.zhekoul + "折，需" + level.jingyanz
				+ "经验值");
		return convertView;
	}

	private static class ViewHolder {
		TextView levelValue;
		TextView levelInfo;
	}

}
